<div *ngIf="pageService">
  <nz-dropdown-menu #rightClickMenu="nzDropdownMenu" (show)="pageService.closeMenu() " style="width:200px;">
    <ul nz-menu style="width:200px;">
      <span *ngIf="pageStatus.checkedFiles.length>0">
        <li nz-menu-item (click)="pageService.downloadClick()">下载</li>
        <li nz-menu-item (click)="pageService.deleteFileClick()">删除</li>
        <span *ngIf="pageStatus.checkedFiles.length==1">
          <li nz-menu-item (click)="pageService.renameFileClick()" >重命名</li>
          <li nz-menu-item (click)="pageService.addToFavorite()">加入收藏</li>
        </span>
        <li nz-menu-item (click)="pageService.copyFileClick()">复制</li>
        <li nz-menu-item (click)="pageService.cutFileClick()">剪贴</li>
        <li *ngIf="!pageStatus.owner.self" nz-menu-item (click)="pageService.reqFilePmClick()">请求文件权限</li>
      <hr style="margin: 0;padding: 0;border:none;border-bottom: 1px solid rgba(0,0,0,.1)">
      </span>
      <li nz-menu-item (click)="pageService.pasteClick()"
          *ngIf="clipboardService.canPaste(pageStatus.currentFile)">粘贴
      </li>
      <li [nzDisabled]="!pageStatus.currentFile.id" nz-submenu nzTitle="新建">
        <ul>
          <li nz-menu-item (click)="pageService.mkDirClick()">文件夹</li>
          <li nz-menu-item onclick="document.form.fileInput.click()" (click)="uploadClick()">上传</li>
          <li nz-menu-item (click)="pageService.createOfflineClick()">离线任务</li>
        </ul>
      </li>
      <li nz-menu-item onclick="location.reload();">刷新</li>
      <li *ngIf="pageStatus.owner.self" nz-menu-item (click)="pageService.ediePermissionClick()">共享设置</li>
      <li nz-menu-item (click)="pageService.detailClick()">详细信息</li>
    </ul>
  </nz-dropdown-menu>
  <form name="form" method="post" action="javascript:;">
    <input type="file" name="fileInput" id="fileInput" style="display: none;" multiple
           (change)="pageService.onUploadFileSelected($event)">
  </form>
  <nz-dropdown-menu #addMenu="nzDropdownMenu">
    <ul nz-menu>
      <li nz-menu-item (click)="pageService.mkDirClick()">
        <button nz-button nzType="primary" nzSize="small" nzGhost><i nz-icon nzType="folder-add"></i>文件夹</button>
      </li>
      <li nz-menu-item onclick="document.form.fileInput.click()">
        <button nz-button nzType="primary" nzSize="small" nzGhost><i nz-icon nzType="upload"></i>上传文件</button>
      </li>
      <li nz-menu-item (click)="pageService.createOfflineClick()">
        <button nz-button nzType="primary" nzSize="small" nzGhost><i nz-icon nzType="cloud-server"></i>离线下载</button>
      </li>
    </ul>
  </nz-dropdown-menu>
  <nz-layout class="layout bby-disk"
             (contextmenu)="pageService.diskPageContextmenuClick($event, rightClickMenu);$event.stopPropagation();">
    <nz-header class="white-back file-op-bt-header">
      <div class="white-back" style="background-color: white;float: left">
        <button [nzDisabled]="!pageStatus.currentFile.id"
          nz-button nzType="primary" nz-dropdown nzTrigger="click" [nzDropdownMenu]="addMenu" style="margin-right: 10px"
          nzSize="default" nzShape="round">
          <i nz-icon nzType="appstore-add" nzTheme="outline"></i>
          新建
        </button>
        <button *ngIf="clipboardService.canPaste(pageStatus.currentFile)"
                (click)="pageService.pasteClick()" nz-button nzType="primary" nzSize="small" nzShape="round" nzGhost>粘贴
        </button>
        <span class="op-com-bt-box" *ngIf="pageStatus.checkedFiles.length>0">
            <button (click)="pageService.downloadClick()" nz-button nzType="primary" nzSize="default" nzShape="round"
                    nzGhost>下载</button>
            <button (click)="pageService.ediePermissionClick()" nz-button nzType="primary" nzSize="default" nzShape="round"
                    nzGhost>共享</button>
            <button (click)="pageService.copyFileClick()" nz-button nzType="primary" nzSize="default" nzShape="round"
                    nzGhost>复制</button>
            <button (click)="pageService.cutFileClick()" nz-button nzType="primary" nzSize="default" nzShape="round"
                    nzGhost>剪贴</button>
            <button (click)="pageService.deleteFileClick()" nz-button nzType="primary" nzSize="default" nzShape="round"
                    nzGhost>删除</button>
          </span>
      </div>
      <form nz-form style="float: right">
        <nz-form-item>
          <nz-input-group class="disk-search-bt-box" nzSearch nzSize="default" [nzSuffix]="inputClearTpl">
            <input type="text" nz-input placeholder="搜索文件" [(ngModel)]="pageStatus.searchInputValue" name="regex"/>
          </nz-input-group>
          <ng-template #inputClearTpl>
            <i
              nz-icon
              class="ant-input-clear-icon"
              nzTheme="fill"
              nzType="close-circle"
              *ngIf="pageStatus.searchInputValue"
              (click)="pageStatus.searchInputValue = ''"
            ></i>
            <button type="submit" nz-button class="disk-search-bt" nzType="default"
                    nzSearch nzSize="small" (click)="pageService.searchClick()">搜索</button>
          </ng-template>
        </nz-form-item>
      </form>
    </nz-header>
    <div class="site-page-header-ghost-wrapper">
      <nz-page-header [nzBackIcon]="pageStatus.currentFile.parent? '' :null" [nzGhost]="false">
        <nz-page-header-title>
          <!--        {{pageStatus.currentFile.parent ? pageStatus.currentFile.name : '全部文件'}}-->
          <!--        <nz-breadcrumb nz-page-header-breadcrumb *ngIf="pageStatus.search">-->
          <!--          <nz-breadcrumb-item>-->
          <!--            <a [routerLink]="'/'+pageName+'/'+pageStatus.currentFile.owner">{{pageStatus.currentFile.name}}</a>-->
          <!--          </nz-breadcrumb-item>-->
          <!--        </nz-breadcrumb>-->
          <nz-breadcrumb nz-page-header-breadcrumb>
            <nz-breadcrumb-item>
              <a [routerLink]="'/'+pageService.rootUrl+'/'+pageStatus.currentFile.owner">{{pageStatus.owner.username}}</a>
            </nz-breadcrumb-item>
            <nz-breadcrumb-item *ngFor="let item of pageStatus.breadcrumb">
              <a [routerLink]="item.link">{{item.title}}</a>
            </nz-breadcrumb-item>
            <nz-breadcrumb-item style="color: grey;font-size: small" *ngIf="pageStatus.search">
              搜索：{{pageStatus.search}}
            </nz-breadcrumb-item>
          </nz-breadcrumb>
        </nz-page-header-title>
        <!--    <nz-page-header-subtitle>This is a subtitle</nz-page-header-subtitle>-->
      </nz-page-header>
    </div>
    <nz-content class="white-back">
      <nz-layout class="white-back">
        <nz-content class="white-back" style="margin-right: 10px">
          <nz-spin nzTip="加载中..." [nzSpinning]="pageStatus.loading" style="height: 100%">
            <nz-empty *ngIf="pageStatus.fileList.length==0" style="margin-top: 10%"
                      nzNotFoundImage="simple" nzNotFoundContent="文件夹空空如也" >
            </nz-empty>
            <nz-table *ngIf="pageStatus.fileList.length>0" #editRowTable [nzData]="pageStatus.fileList" style="height: 100%"
                      [nzScroll]="{ y: '550px' }" nzShowPagination="false" nzBordered="false">
              <thead>
              <tr>
                <th nzWidth="25px" [(nzChecked)]="pageStatus.all_checked" (nzCheckedChange)="pageService.onAllChecked($event)"></th>
                <th >名称</th>
                <th nzWidth="200px">大小</th>
                <th nzWidth="200px">修改日期</th>
                <th>共享状态</th>
                <th>建立者</th>
              </tr>
              </thead>
              <tbody>
              <tr *ngFor="let file of editRowTable.data;"
                  (contextmenu)="pageService.contextMenu($event, rightClickMenu,file);$event.stopPropagation();"
                  (click)="pageService.onAllChecked(false);pageService.onItemChecked(file,!file.checked);"
                  (dblclick)="pageService.fileDoubleClick(file)">
                <td [nzChecked]="file.checked==true" (nzCheckedChange)="pageService.onItemChecked(file, $event);"
                    (click)="$event.stopPropagation();"></td>
                <td><img style="width: 20px" [src]="pageService.getImgURL(file)" alt="未知类型"> {{file['name']}}</td>
                <!--          <td>{{ file.type }}</td>-->
                <td>{{ (file.size | nzBytes) || '-' }}</td>
                <td>{{ file.lastModified | date:'yyyy-MM-dd HH:mm:ss'}}</td>
                <td>
                  <nz-tag *ngIf="file.permission?.ann?.open" nzColor="orange">ann</nz-tag>
                  <nz-tag *ngIf="file.permission?.user?.open" nzColor="green">user</nz-tag>
                  <nz-tag *ngIf="file.permission?.custom?.open" nzColor="blue">custom</nz-tag>
                </td>
                <td><a (click)="openUser(file.maker)">{{getUserName(file.maker)}}</a></td>
              </tr>
              </tbody>
            </nz-table>
          </nz-spin>
        </nz-content>
        <nz-sider nzTheme="light" nzWidth="260px" style=" margin-right: 10px">
          <bby-file-info [checkedFiles]="pageStatus.checkedFiles" [rootUrl]="pageService.rootUrl"
                         [path]="pageStatus.open_path"></bby-file-info>
        </nz-sider>
      </nz-layout>
    </nz-content>
  </nz-layout>
</div>
